package com.ybkj.o2o.zhuanche.common.query;

import org.apache.commons.lang.StringUtils;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created by YH on 16/10/20.
 */
public class Car2Query {
  
  private Long companyId;
  
  private String companyName;
  
  private String carType;
  
  private String carNumber;
  
  private String employName;
  
  private String status; //0 空闲 ,1 忙碌 , 2 离线
  
  private String isPlatforms;//是否上传监管平台，0 未上传；1，已上传
  
  private String appKey;

  private Integer page;

  private Integer rows;

  private Integer offset;
  
  private Date overhaul; //查询年检日期到期的车辆
  
  private Date insurance; //查询保险到期的车辆
  
  private Long rentalCompanyId; //租赁公司id
  
  public String getIsPlatforms() {
	return isPlatforms;
}

public void setIsPlatforms(String isPlatforms) {
	this.isPlatforms = isPlatforms;
}

public Date getOverhaul() {
    return overhaul;
  }

  public void setOverhaul(Date overhaul) {
    this.overhaul = overhaul;
  }

  public Date getInsurance() {
    return insurance;
  }

  public void setInsurance(Date insurance) {
    this.insurance = insurance;
  }
  
  public Long getRentalCompanyId() {
    return rentalCompanyId;
  }

  public void setRentalCompanyId(Long rentalCompanyId) {
    this.rentalCompanyId = rentalCompanyId;
  }

  private String rentalCompanyName;  //租赁公司名称
  
  public String getRentalCompanyName() {
    return rentalCompanyName;
  }

  /**
   * 模糊查询.
   */
  
  public void setRentalCompanyName(String rentalCompanyName) {
    if (StringUtils.isNotBlank(rentalCompanyName)) {
      this.rentalCompanyName = "%" + rentalCompanyName + "%";
    } else {
      this.rentalCompanyName = null;
    }
  }

  public Long getCompanyId() {
    return companyId;
  }

  public void setCompanyId(Long companyId) {
    this.companyId = companyId;
  }

  public String getCompanyName() {
    return companyName;
  }
  /**
   * 模糊查询.
   */
  
  public void setCompanyName(String companyName) {
    if (StringUtils.isNotBlank(companyName)) {
      this.companyName = "%" + companyName + "%";
    } else {
      this.companyName = null;
    }
  }

  public String getCarType() {
    return carType;
  }
  /**
   * 模糊查询.
   */
  
  public void setCarType(String carType) {
    if (StringUtils.isNotBlank(carType)) {
      this.carType = "%" + carType + "%";
    } else {
      this.carType = null;
    }
  }

  public String getCarNumber() {
    return carNumber;
  }
  /**
   * 模糊查询.
   */
  
  public void setCarNumber(String carNumber) {
    if (StringUtils.isNotBlank(carNumber)) {
      this.carNumber = "%" + carNumber + "%";
    } else {
      this.carNumber = null;
    }
  }

  public String getEmployName() {
    return employName;
  }
  /**
   * 模糊查询.
   */
  
  public void setEmployName(String employName) {
    if (StringUtils.isNotBlank(employName)) {
      this.employName = "%" + employName + "%";
    } else {
      this.employName = null;
    }
  }

  public String getStatus() {
    return status;
  }

  public void setStatus(String status) {
   
    this.status = status;
  }
  /**
   * 模糊查询.
   */
  
  public List<Integer> getStatusList() {
    if (StringUtils.isNotBlank(this.status)) {
      String[] split = this.status.split(",");
      List<Integer> ss = new ArrayList<Integer>();
      for (String temp : split) {
        ss.add(Integer.parseInt(temp));
      }
      return ss;
    }
    return null;
  }
  
  /**
   * 是否上传监管平台查询.
   */
  
  public List<Integer> getPlatformList() {
	  if (StringUtils.isNotBlank(this.isPlatforms)) {
		  String[] split = this.isPlatforms.split(",");
		  List<Integer> ss = new ArrayList<Integer>();
		  for (String temp : split) {
			  ss.add(Integer.parseInt(temp));
		  }
		  return ss;
	  }
	  return null;
  }

  public String getAppKey() {
    return appKey;
  }

  public void setAppKey(String appKey) {
    this.appKey = appKey;
  }

  public Integer getPage() {
    return page;
  }

  public void setPage(Integer page) {
    this.page = page;
  }

  public Integer getRows() {
    return rows;
  }

  public void setRows(Integer rows) {
    this.rows = rows;
  }

  /**
   * 根据page和rows计算出偏移量.
   */
  
  public Integer getOffset() {
    if (getPage() == null || getRows() == null) {
      return null;
    }
    if (getPage() >= 1) {
      return (getPage() - 1) * getRows();
    }

    return offset;
  }

  public void setOffset(Integer offset) {
    this.offset = offset;
  }

  @Override
  public String toString() {
    return "Car2Query [companyId=" + companyId + ", companyName=" + companyName + ", carType="
        + carType + ", carNumber=" + carNumber + ", employName=" + employName + ", status="
        + status + ", appKey=" + appKey + ", page=" + page + ", rows=" + rows + ", offset="
        + offset + " , statusList=" + getStatusList() + "]";
  }


}
